package com.pcl;

import lombok.extern.slf4j.Slf4j;

import java.util.Date;

/**
 *
 * @author 潘春龙
 * @title: ProjectSix
 * @projectName learn-git-testing
 * @description: TODO
 * @date 2022/2/17
 */
@Slf4j
public class ProjectSix {
  public static void main(String[] args) {
    long a= new Date().getTime();
    String cc="";
    int n=10000;
    for (int i = 0; i < n; i++) {
      cc+="."+i;
    }
    log.info("String使用的时间"+(System.currentTimeMillis()-a)/1000.0+"s");
    long s1=System.currentTimeMillis();
    StringBuilder sb=new StringBuilder();
    for (int i = 0; i < n; i++) {
      sb.append("."+i);
    }
    log.info("StringBuilder使用的时间"+(System.currentTimeMillis()-s1)/1000.0+"s");
    long s2=System.currentTimeMillis();
    StringBuffer sbf=new StringBuffer();
    for (int i = 0; i < n; i++) {
      sbf.append("."+i);
    }
    log.info("StringBuffer使用的时间"+(System.currentTimeMillis()-s2)/1000.0+"s");
  }
}
